<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>

<%@ include file="navbar.jsp" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    
    <title>My JSP 'new_document.jsp' starting page</title>
	<link rel="stylesheet" type="text/css" href="styles/css/bootstrap.min.css" />
	<link rel="stylesheet" href="styles/ueditor/themes/default/ueditor.css"> 
  </head>
  
  <body class="body">
    <div class="container" style="margin-top:60px;width:960px;margin-left:auto;margin-right:auto;">
	  <div class="row">
	
	
	 <!-- 导入左侧部分 -->
		<jsp:include page="side.jsp">
			<jsp:param value="document" name="tag"/>
		</jsp:include>
	
	
	<div class="span9">
	 <form action="document.jspx?m=add" method="post" id="myform">
        <fieldset>
          <legend>分享新资料</legend>
          <div class="control-group">
            <label class="control-label" for="input01">标题</label>
            <div class="controls">
              <input type="text" class="span9" id="documentName" x-webkit-speech="undefined" name="documentName" style="height:30px" ><br />
           	  <span id="span1" style="color:red;"></span>
            </div>
          </div>
		  <div class="control-group"  >
            <label class="control-label" for="input01">内容</label>
            
            
            <!-- 此处为文本编辑器的内容，表单的默认名为editorValue,在servlet中只需获得这个这个表单名即可获得所有的内容 -->
            <div id="myEditor"></div>
				<script type="text/plain" id="editor">
  				  
				</script>
				
            </div>
           
		
		
		
          <div class="form-actions">
            <button type="submit"  class="btn btn-primary" id="btnSubmit">保存</button>
            <a href="document.jspx" class="btn">返回</a>
          </div>

        </fieldset>
      </form>          
          	
		</div>
		<div class="span3">
			
		</div>
	  </div>
	</div>
	
	
	
	<script type="text/javascript" src="styles/jquery/jquery.js"></script>
	<script type="text/javascript" src="styles/ueditor/editor_all.js"></script> 
	<script type="text/javascript" src="styles/ueditor/editor_config.js"></script>
	
	<script type="text/javascript">
	    var editor = new baidu.editor.ui.Editor();
	    editor.render("myEditor");
	
		$(document).ready(function(){
			$("#btnSubmit").click(function(){
				var documentName = $("#documentName").val();
				if(documentName.trim().length == 0){
					$("#span1").html("资料标题不能为空！");
					$("#documentName").focus();
					return;
				} else if(documentName.length > 10){
					$("#span1").html("资料标题长度不能大于10");
					$("#documentName").focus();
					return;										
				}
				
				
				
				
				$("#myform").submit();
			
			
			
				
			});
		});
	</script>
  </body>
</html>
